<template>
	<view>
		<web-view :webview-styles="webviewStyles" :src="urls" @message="getmessage"></web-view>
	</view>
</template>

<script>
	import imageurl from '@/common/request/routerUrl.js'
	export default {
		data() {
			return {
				webviewStyles: {
					progress: {
						color: '#FF3333'
					}
				},
				urls: '',
				token: '',
				fenxiang: ''
			}
		},
		onLoad() {
			this.getURL()
		},
		methods: {
			getURL() {
				this.$request.invitedNewPageAPI().then(res => {
					this.fenxiang = res.data.url_share
					let header = Object.assign({
						'content-type': "application/x-www-form-urlencoded"
					}, {
						token: uni.getStorageSync("token")
					})
					this.urls = res.data.url_my + '?token=' + uni.getStorageSync("token")
				})
			},
			getmessage(e) {
				console.log('接收到的消息：' + JSON.stringify(e.detail.data));
				this.clickWXshare(this.fenxiang)
			},
			// 分享函数
			clickWXshare(url) {
				let shareData = {
					url,
					title: 'AI智能填志愿，不浪费分上好大学，速领红包→',
					summary: '点我领60元红包',
					img: imageurl + '/static/invite/invite.png'
				}
				console.log('分享数据', shareData);
				uni.navigateTo({
					url: '/components/share-footer/share-footer?data=' + encodeURIComponent(JSON.stringify(
						shareData))
				})
			},
		}
	}
</script>

<style>

</style>